package io.arukas.domain.audit;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.CreationTimestamp;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * Created by IntelliJ IDEA. <br/>
 * Author: YuXian Niu <br/>
 * Email: niuyuxian@163.com <br/>
 * Create: 2021-08-15 21:35 <br/>
 */
@Data
@MappedSuperclass
@EqualsAndHashCode(callSuper = true)
@EntityListeners(AuditingEntityListener.class)
@JsonIgnoreProperties(
        value = {"createdAt", "updatedAt"},
        allowGetters = true
)
public class DateAudit extends IdEntity implements Serializable {

    // Instant
    @CreatedDate
    private LocalDateTime createdAt;

    @Column(length = 0)
    @LastModifiedDate
    private LocalDateTime updatedAt;
}
